package vsvm.gui.forms;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JLabel;
import javax.swing.JPanel;

import vsvm.gui.VSVMInternalFrame;

public class ChessTestFrame extends VSVMInternalFrame {
	private boolean[][] m;
	private JPanel c;
	
	public ChessTestFrame(String title, boolean[][] mx) {
		super(title);
		this.m = mx;		
		setLayout(new FlowLayout());

		c = new JPanel() {
			private Image back = null;
			
			public void paint(Graphics gr) {
				
				if (back == null) {
					int n = 2;
					back = createImage(m.length*n, m[0].length*n);
					Graphics g = back.getGraphics();
					for (int i = 0; i < m.length; ++i) {
						for (int j = 0; j < m[i].length; ++j) {
							g.setColor(m[i][j]?new Color(255, 0, 0):new Color(0,0,255));
							g.fillRect(n*i, n*j, n, n);
						}
					}
				}
				
				gr.drawImage(back, 0, 0, null);
			}
		};
		c.setPreferredSize(new Dimension(m.length*2, m.length*2));
		//this.add(c, BorderLayout.CENTER);
		this.add(c);
	}


}
